package com.etone.smartAudit.controller;

import com.etone.smartAudit.domain.work.WorkRectifyTemplate;
import com.etone.smartAudit.service.WorkRectifyTemplateService;
import com.etone.smartAudit.vo.workOrder.WorkRectifyTemplateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author 张任豪
 */
@RestController
@AllArgsConstructor
@Api(tags = "整改反馈模板", value = "WorkRectifyTemplateController")
public class WorkRectifyTemplateController {

    private WorkRectifyTemplateService workRectifyTemplateService;

    @ApiOperation(value = "批量反馈模板导入")
    @PostMapping("/workRectify/batchRefusalTemplate")
    public WorkRectifyTemplateVO batchRefusalTemplate(
            @ApiParam(value = "导入反馈信息") @RequestPart MultipartFile file) {
        return workRectifyTemplateService.batchRefusalTemplate(file);
    }

    @ApiOperation(value = "批量反馈模板添加")
    @PostMapping("/workRectify/batchAddTemplate")
    public void batchAddTemplate(
            @ApiParam(value = "反馈模板数据") @RequestBody List<WorkRectifyTemplate> templates
    ) {
        workRectifyTemplateService.saveAll(templates);
    }

    @ApiOperation(value = "下载反馈工单")
    @GetMapping("/workOrderPend/feedBackTemplate/{ids}")
    public void feedBackTemplate(@ApiParam("工单整合id") @PathVariable List<Integer> ids,HttpServletResponse response) {
        workRectifyTemplateService.feedBackTemplate(ids,response);
    }

}
